ifeq (${MAKECMDGOALS}, debug)
	cflag = -g
	dir = ./debug
else
	cflag = -O2 -DNDEBUG
	lflag = -s
	dir = ./release
endif

module = libshare.a
target = ${dir}/${module}
sources = ${shell ls *.cpp sql/*.cpp}
objects = ${patsubst %.cpp, ${dir}/%.o, ${sources}}
headers = ${shell ls *.h 2>/dev/null}
boost_libs = -L/usr/lib -lboost_date_time -lboost_system -lboost_thread

${shell mkdir -p ${dir}}

release debug : ${target}
${target} : ${objects}
	ar -r -o ${target}  ${objects} 
${objects} : ${dir}/%.o : %.cpp ${headers}
	g++ -Wall -fexceptions -std=c++11 ${cflag} -c $< -o $@
	#g++ -Wall -fexceptions  ${cflag} -c $< -o $@


.PHONY : clean
clean:
	-rm -rf ./debug/*.* ./release/*.*
cp:
	 \cp -f ./release/${module} ../../src/libs
